package com.作业.Day7.com;

public class Homework8 {
    public static void main(String[] args) {
        // 创建Computer对象并测试功能
        Computer computer1 = new Computer("联想", "i5", 8, 1);
        System.out.println(computer1.connect());
        System.out.println("内存大小: " + computer1.getEmsSize() + "GB");
        System.out.println("硬盘大小: " + computer1.getHardDiskSize() + "TB");
    }
}

// CPU接口，使用大驼峰命名法
interface Cpu {
    CpuInfo connect();
}

// CPU信息类
class CpuInfo {
    private String brand;
    private String model;

    public CpuInfo(String brand, String model) {
        this.brand = brand;
        this.model = model;
    }

    @Override
    public String toString() {
        return "CpuInfo{" +
                "brand='" + brand + '\'' +
                ", model='" + model + '\'' +
                '}';
    }
}

// 内存接口
interface Ems {
    int getEmsSize();
}

// 硬盘接口
interface HardDisk {
    int getHardDiskSize();
}

// 计算机类，实现所有接口
class Computer implements Cpu, Ems, HardDisk {
    private String brand;
    private String cpuModel;
    private int emsSize;  // 内存大小（GB）
    private int hardDiskSize;  // 硬盘大小（TB）

    public Computer(String brand, String cpuModel, int emsSize, int hardDiskSize) {
        this.brand = brand;
        this.cpuModel = cpuModel;
        this.emsSize = emsSize;
        this.hardDiskSize = hardDiskSize;
    }

    @Override
    public CpuInfo connect() {
        System.out.println("连接CPU: " + brand + " " + cpuModel);
        return new CpuInfo(brand, cpuModel);
    }

    @Override
    public int getEmsSize() {
        return emsSize;
    }

    @Override
    public int getHardDiskSize() {
        return hardDiskSize;
    }
}